
package com.yuan.servlet;

import com.yuan.hibernate.请假申请;
import com.yuan.hibernate.请假申请DAO;
import com.yuan.util.CommUtil;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class cancelleaveservlet extends BaseHttpServlet {
    private 请假申请DAO m请假申请DAO = null;
    private 请假申请 m请假申请 = null;

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        super.doGet(request, response);
        m请假申请DAO = new 请假申请DAO();
        int leaveid = Integer.parseInt(request.getParameter("leaveid"));
        m请假申请 = m请假申请DAO.findById(leaveid);
        String state = m请假申请.get状态();
        try
        {
            if (CommUtil.checkNoNull(state)) {
                mResponse = "在审批中，不可删除";
            } else {
                m请假申请DAO.delete(m请假申请);
                mResponse = "删除成功";
            }
        } catch (Exception e)
        {
            e.printStackTrace();
        }
        closeAndClear();
    }

    protected synchronized void closeAndClear() {
        m请假申请DAO = null;
        m请假申请 = null;
        super.closeAndClear();
    }
}
